﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CMN.BLL;
using CMN.Common;
using CMN.Entity;
using CMN.Models.Interfaces;
namespace CMN.Models
{
    /// <summary>
    /// 模块扩展权限Service
    /// </summary>
    public class Sys_ModuleExtPermissionService: IDataService<Sys_ModuleExtPermissionEntity>
    {
        /// <summary>
        /// 新增模块扩展权限
        /// </summary>
        /// <param name="Sys_ModuleExtPermissionEntity"></param>
        /// <returns>bool</returns>
        public string Insert(Sys_ModuleExtPermissionEntity sys_moduleextpermissionEntity)
        {
            sys_moduleextpermissionEntity.DataTable_Action = DataTableAction.Insert;
            BLLHelper bll = new BLLHelper();
            if (bll.Sys_ModuleExtPermissionInsertUpdateDelete(sys_moduleextpermissionEntity) > 0)
            {
                return "";
            }
            else
            {
                return "失败";
            }
        }

        /// <summary>
        /// 返回模块扩展权限查询列表
        /// </summary>
        /// <param name="qp"></param>
        /// <param name="count">查询总个数</param>
        /// <returns>List</returns>
        public List<Sys_ModuleExtPermissionEntity> List(QueryParam qp,out int count)
        {
            BLLHelper bll = new BLLHelper();
            return bll.Sys_ModuleExtPermissionList(qp, out count);
        }

        /// <summary>
        /// 更新模块扩展权限
        /// </summary>
        /// <param name="Sys_ModuleExtPermission"></param>
        /// <returns>bool</returns>
        public string Update(Sys_ModuleExtPermissionEntity sys_moduleextpermissionEntity)
        {
            sys_moduleextpermissionEntity.DataTable_Action = DataTableAction.Update;
            BLLHelper bll = new BLLHelper();
            if (bll.Sys_ModuleExtPermissionInsertUpdateDelete(sys_moduleextpermissionEntity) > 0)
            {
                return "";
            }
            else
            {
                return "失败";
            }
        }

        /// <summary>
        /// 删除模块扩展权限
        /// </summary>
        /// <param name="Sys_ModuleExtPermission"></param>
        /// <returns>bool</returns>
        public string Delete(Sys_ModuleExtPermissionEntity sys_moduleextpermissionEntity)
        {
            sys_moduleextpermissionEntity.DataTable_Action = DataTableAction.Delete;
            BLLHelper bll = new BLLHelper();
            if (bll.Sys_ModuleExtPermissionInsertUpdateDelete(sys_moduleextpermissionEntity) > 0)
            {
                return "";
            }
            else
            {
                return "失败";
            }
        }

        /// <summary>
        /// 批量删模块扩展权限
        /// </summary>
        /// <param name="idList">删除id列表  2_8_9_45</param>
        /// <returns>bool</returns>
        public string DeleteList(string idList)
        {
            string[] list =Utils.SplitString(idList,"_");
            string strDel=Utils.ArrayToString(list,",",false);
            BLLHelper bll = new BLLHelper();
            if (bll.Sys_ModuleExtPermissionDelList(strDel) > 0)
            {
                return "";
            }
            else
            {
                return "失败";
            }

        }

        /// <summary>
        /// 返回单个模块扩展权限
        /// </summary>
        /// <param name="id"></param>
        /// <returns>Sys_ModuleExtPermissionEntity</returns>
        public Sys_ModuleExtPermissionEntity Look(int id)
        {
            BLLHelper bll = new BLLHelper();
            return bll.Sys_ModuleExtPermissionDisp(id);
        }
    }
}
